/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 26727
 * Date: 2024-01-15
 * Time: 11:00
 */
public class Hanoi {
        public static void hanoi(int n,char pos1,char pos2,char pos3) {
              if(n == 1) {
                  move(pos1,pos3);
                  return;
              }
              hanoi(n-1,pos1,pos3,pos2);
              move(pos1,pos3);
              hanoi(n-1,pos2,pos1,pos3);
        }
        //从某一个位置移动到某一个位置
        public static void move(char pos1,char pos2) {
            System.out.println(pos1+"->"+pos2);
        }

        public static void main(String[] arg) {
            hanoi(1,'A','B','C');
            System.out.println();
            hanoi(2,'A','B','C');
            System.out.println();
            hanoi(3,'A','B','C');
            System.out.println();
        }
    }
